/// 自定义线程池
#[cfg(test)]
mod tests {
    use std::sync::atomic::{AtomicUsize, Ordering};
    use std::sync::Arc;

    #[test]
    #[should_panic]
    fn test_safe_thread_pool() {
        let thread_pool = thread_pool::with_threads(10).build();
        let test_count = Arc::new(AtomicUsize::new(0));
        for _ in 0..42 {
            let test_count = test_count.clone();
            thread_pool.execute(move || {
                test_count.fetch_add(1, Ordering::Relaxed);
            });
        }
        thread_pool.join();
        assert_eq!(42, test_count.load(Ordering::Relaxed));

        let t = T(1);
        panic!("test panic drop");
        println!("before drop test");
    }

    struct T(i32);

    impl Drop for T {
        fn drop(&mut self) {
            println!("Dropping test value = {}", self.0);
        }
    }
}
